<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    </style>
</head>
<body>
    <div id="app">
        <h1>app</h1>
        <p>msg:{{msg}}</p>
        <book>
            <template #default >
                <div>作者：罗贯中</div>
                <img src="./imgs/logo.png">
            </template>
            <template #s2="son">
                <div>我是插槽02：{{son.data}}</div>
                <div>我是插槽02</div>
            </template>
        </book>
    </div>
</body>
</html>
<script src="./js/vue.global.js"></script>
<script>

   
    let Book = {
        template:`           
           <h1>书籍信息：</h1>
            <div>
                <p>书名：三国演义</p>
                <slot>
                    <p>作者:罗贯中</p>
                </slot>
                <hr/>
                <slot name="s2" :data="sonMsg"></slot>
            </div>
        `,
        data(){
            return {
                sonMsg:"我是子组件的数据"
            }
        },
        mounted(){
            console.log("this.$slots",this.$slots);
        }
    }

   

     let app = Vue.createApp({
        data(){
            return {
                msg:"hello" 
            }
        },
        methods:{
            changeFn(str){
                console.log("父组件中获得的子组件的值：",str);
            }
        }
    });

    // book组件是在app上全局注册的。
    app.component("book",Book);
    

    app.mount("#app");
    



</script>